﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demo1
{
    class Class1
    {
        static void a()
        {
            int max;
            int min;
            double avg;
            int[] arr = { 20, 30, 10, 340, 20, 420 };
            int sum = GetSum(arr, out max, out min, out avg);
            Console.WriteLine("总和为 = {0},max = {1},min = {2},avg = {3}", sum, max, min, avg);
        }
        static int GetSum(int[] arr, out int max, out int min, out double avg)
        {
            int sum = 0;
            foreach (var item in arr)
            {
                sum += item;
            }
            max = arr[0];
            min = arr[0];
            for (int i = 0; i < arr.Length; i++)
            {
                if (arr[i] > max)
                {
                    max = arr[i];
                }
                if (arr[i] < min)
                {
                    min = arr[i];
                }
            }
            avg = sum * 1.0 / arr.Length;
            return sum;

        }
    }
}
